import 'package:flutter_ncsjqz_getx/http/dio_service.dart';
import 'package:flutter_ncsjqz_getx/model/msg_count_entity.dart';
import 'package:flutter_ncsjqz_getx/model/platform_msg_entity.dart';
import 'package:flutter_ncsjqz_getx/model/sys_notice_entity.dart';
import 'package:get/get.dart';

class MessageLogic extends GetxController {
  List<SysNoticeData>? sysNoticeData = [SysNoticeData()..msgTitle=''];
  List<PlatformMsgDataList>? platformMsgList = [PlatformMsgDataList()];
  List<PlatformMsgDataList>? plMsgList = [PlatformMsgDataList()];
  MsgCountData? msgCountData = MsgCountData()..interactiveCount = 0..noticeCount = 0..noticeCount =0..platformCount =0..totalCount =0;

  /// 获取系统公告
  getSysNotice() async{
    SysNoticeEntity sysNoticeEntity = await DioService<SysNoticeEntity>().v2_listSysNotice();
    sysNoticeData = sysNoticeEntity.data;
    update();
  }

  /// 获取统计
  getMsgCount() async{
    MsgCountEntity msgCountEntity = await DioService<MsgCountEntity>().statisticsMsgCount();
    if(msgCountEntity.code == 0 && msgCountEntity.data != null){
      msgCountData = msgCountEntity.data;
    }
    update();
  }

  /// 获取平台、评论消息
  getPtAndPlMessage() async{
    PlatformMsgEntity platformMsgEntity1 = await DioService<PlatformMsgEntity>().messagePage({
      "pageSize": 10,
      "currPage": 0,
      "msgType": 1, //1 平台 3评论
    });
    PlatformMsgEntity platformMsgEntity2 = await DioService<PlatformMsgEntity>().messagePage({
      "pageSize": 10,
      "currPage": 0,
      "msgType": 3, //1 平台 3评论
    });
    if(platformMsgEntity1.code==0 && platformMsgEntity1.data!=null){
      platformMsgList = platformMsgEntity1.data!.xList;
      plMsgList = platformMsgEntity2.data!.xList;
    }
    update();
  }


}
